package Dao.Impl;

import Bean.Page;
import Dao.BasicDao;
import Dao.PageDao;
import Utils.DBHelp;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.sql.SQLException;
import java.util.List;


import static com.alibaba.druid.sql.dialect.oracle.ast.expr.OracleSizeExpr.Unit.T;

public class PageDaoImpl extends BasicDao implements PageDao {
    public static void main(String[] args) {
        PageDaoImpl pageDao = new PageDaoImpl();
        String sql ="select  count(*) from furn;";
        System.out.println(pageDao.getCount(sql));
    }
    @Override
    public Integer getCount(String sql) {
        QueryRunner queryRunner = new QueryRunner();
        Integer index = 0;
        try {
           Long update = (Long)queryRunner.query(DBHelp.getConnection(), sql,new ScalarHandler());
           index = update.intValue();
        } catch (SQLException e) {
            index = -1;
        }
        return index;
    }
    @Override
    public List getLimitT(String sql, Object... nums) {
        return List.of();
    }
}
